<?php
require_once 'PHPUnit/Framework.php';
require_once 'TVB/PWORKS/util/CommonUtil.class.php';

class UnpublishTest extends PHPUnit_Framework_TestCase
{
	public static $programme_id = 291;
	public static $episode_id = 630;

    public function testUnpublishProgramme()
    {
		$url = 'http://pdes.tvb.com/programme_switch.html?ut=true';
		$params = array(
			'unpublish' => 1,
			'id' => self::$programme_id,
			'pt' => 1
		);

		$ret = CommonUtil::curl_test($url, $params);
		$err_num = count(json_decode($ret));

		if ($err_num == 0) {
            echo '========UnpublishProgrammeTest pass!===================' . "\n";
		}

		$this->assertEquals($err_num, 0); 	
	}

	public function testUnpublishEpisode()
	{
		$url = 'http://pdes.tvb.com/episode_switch.html?ut=true';
		$params = array(
			'unpublish' => 1,
			'id' => self::$episode_id,
			'pt' => 1
		);

		$ret = CommonUtil::curl_test($url, $params);
		$err_num = count(json_decode($ret));

		if ($err_num == 0) {
            echo '========UnpublishEpisodeTest pass!===================' . "\n";
		}

		$this->assertEquals($err_num, 0); 	
	}
}

